const companiesModels=require('../models/Companies')


class companiesService{
    async findAllCompanies(){
      return  await companiesModels.findAllCompanies();
    }

    async finCompaniesById(id){
        if(!id){
            throw new Error('Id is must required!')
        }
        return await companiesModels.finCompaniesById(id);
    }

    async createCompany(companyData){
        if(!companyData){
            throw new Error('content is must required!')
        }
        return await companiesModels.creatCompany(companyData);
    }

    async updateCompany(company_id, data){
        const result= await companiesModels.updateCompany(company_id, data);
        if (!result){
            throw new Error('没有找到该公司Id的信息');
        }
        return { ...data}
    }

    async updateCompanyLogo(data){
        if(!data){
            throw new Error('请求数据为空');
        }
        const result = await companiesModels.updateCompanyLogo(data);
        if(!result){
            throw new Error('没有找到该公司的信息')
        }
        return { ...data }
    }
}




module.exports = new companiesService();